package tree.easy;

import tree.TreeNode;

/**
 * 100. 相同的树
 */
public class isSameTree {
    public static void main(String[] args) {
        TreeNode root1 = null;
        TreeNode root2 = new TreeNode(1, null, new TreeNode(2));
        isSameTree t = new isSameTree();
        System.out.println(t.preorder(root1, root2));
    }

    public boolean myCode(TreeNode p, TreeNode q) {
        return false;
    }

    public boolean preorder(TreeNode p, TreeNode q) {
        if (p == null && q == null) {
            return true;
        } else if (p == null || q == null) {
            return false;
        } else if (p.val != q.val) {
            return false;
        } else {
            return preorder(p.left, q.left) && preorder(p.right, q.right);
        }

    }
}
